<template>
  <div class="homeBox">
    <van-button type="primary" @click="goBack">返回</van-button>
    <div v-html="body"></div>
  </div>
</template>

<script>
import { API_DETAIL } from '@/api'

export default {
  name: 'Detail',
  data() {
    return {
      body: ''
    }
  },
  async created() {
    const { id } = this.$route.params
    const { body, css, image } = await API_DETAIL(id)
    let link = document.getElementById('link')
    if (!link) {
      link = document.createElement('link')
      link.id = 'link'
      link.href = css[0]
      link.rel = 'stylesheet'
      document.head.appendChild(link)
    }

    this.body = body
  },
  methods: {
    goBack() {
      this.$router.back()
    }
  }
}
</script>
